# Maintainer: Antoine Martin <totaam@xpra.org>

_realname=pyopengl
_pyname=PyOpenGL
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_pyname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_pyname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_pyname}")
pkgver=3.1.5
pkgrel=1
pkgdesc="PyOpenGL is the most common cross platform Python binding to OpenGL and related APIs (mingw-w64)"
arch=('any')
url='http://pyopengl.sourceforge.net'
license=('PyOpenGL')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
_dtoken='b8/73/31c8177f3d236e9a5424f7267659c70ccea604dab0585bfcd55828397746'
_acceltoken='a2/3c/f42a62b7784c04b20f8b88d6c8ad04f4f20b0767b721102418aad94d8389'
source=("https://files.pythonhosted.org/packages/${_dtoken}/${_pyname}-${pkgver}.tar.gz"
        "https://files.pythonhosted.org/packages/${_acceltoken}/${_pyname}-accelerate-${pkgver}.tar.gz")
sha512sums=('5d90fc68040b4886e46ff69a59be9e3a8e31e3e1295283756db86d50a1efe681986928e18eb55d20fd2660f863653301ea483425bbe24046f55085b44f4906eb'
            '60a0305bd517f761ef4a01a590162037bf84fa01315c505c3e7d8bd6091d10929281315a467cc4a8ee837c881f498c6d77ed161bc047eb87968606047e0b8be0')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname}-${pkgver}" "python-build-${CARCH}"
  cp -r "${_pyname}-accelerate-${pkgver}" "python-build-${CARCH}-accelerate"
  echo "TODO" > "python-build-${CARCH}/readme.rst"
  echo "TODO" > "python-build-${CARCH}-accelerate/readme.rst"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
  msg "accelerate module:"
  cd "${srcdir}/python-build-${CARCH}-accelerate"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py check
  cd "${srcdir}/python-build-${CARCH}-accelerate"
  ${MINGW_PREFIX}/bin/python setup.py check
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"

  cd "${srcdir}/python-build-${CARCH}-accelerate"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
